"""Added ads, searchOrder  tables

Revision ID: a8e106086bd0
Revises: 3c5972869ca7
Create Date: 2024-04-10 22:32:22.719173

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "a8e106086bd0"
down_revision: Union[str, None] = "3c5972869ca7"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "search_order",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("rubric_url", sa.String(length=250), nullable=True),
        sa.Column("query_string", sa.String(length=320), nullable=False),
        sa.Column("deep_pages", sa.Integer(), nullable=False),
        sa.Column("city", sa.String(), nullable=True),
        sa.Column("main_url", sa.String(length=32), nullable=True),
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("user_id", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "ads",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("title", sa.String(length=50), nullable=False),
        sa.Column("price", sa.Integer(), nullable=True),
        sa.Column("currency", sa.String(length=8), nullable=True),
        sa.Column("descriptions", sa.String(length=256), nullable=False),
        sa.Column("url", sa.String(length=256), nullable=False),
        sa.Column("data_marker", sa.String(length=32), nullable=False),
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("order_id", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ["order_id"],
            ["search_order.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("ads")
    op.drop_table("search_order")
    # ### end Alembic commands ###
